#include <vector>
#include <iostream>
#include <stack>
#include <sstream>
using namespace std;
class Solution
{
public:
    int evalRPN(vector<string> &tokens)
    {

        stack<int> operands;
        int length = tokens.size();
        int numA = 0;
        int numB = 0;
        for (int i = 0; i < length; i++)
        {
            string &operand = tokens[i];
            char c = operand[0];
            if (operand.length() == 1 && !isdigit(c))
            {
                numB = operands.top();
                operands.pop();
                numA = operands.top();
                operands.pop();
                switch (c)
                {
                case '+':
                    operands.push(numA + numB);
                    break;
                case '-':
                    operands.push(numA - numB);
                    break;
                case '*':
                    operands.push(numA * numB);
                    break;
                case '/':
                    operands.push(numA / numB);
                    break;
                }
            }
            else
            {
                operands.push(stoi(operand));
            }
        }
        return operands.top();
    }
};
int main(int argc, char const *argv[])
{
    vector<string> v = {"10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"};
    Solution s;
    cout << s.evalRPN(v) << endl;
    return 0;
}
